package com.example.serverSide.controller;

import com.example.serverSide.commom.ResultData;
import com.example.serverSide.commom.dto.MenuDto;
import com.example.serverSide.pojo.Menu;
import com.example.serverSide.service.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("menu")
public class MenuController {
    @Autowired
    MenuService menuService;
    @GetMapping("/getMenus")
    public ResultData getMenus() {
        List<Menu> menus = menuService.getMenus();
        return ResultData.success(menus);
    }
    @GetMapping("/getMenuOption/{id}")
    public ResultData getMenuOption(@PathVariable("id") Long id) {
        List<MenuDto> list = menuService.getMenuOption(id);
        return ResultData.success(list);
    }
}
